<template>
    <div class="box">
        <header class="header">
            我的
        </header>
        <div class="content">
            <div style="display:flex;justify-content: space-between;">
                <p> 用户名：{{ username }}</p>
                <van-button type="default" size="small" @click="loginout">退出登录</van-button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            username: localStorage.getItem('username')
        }
    },
    methods: {
        loginout() {
            // 清除token
            localStorage.removeItem('token')
            // 清除用户名
            localStorage.removeItem('username')
            // 跳转到登录页面
            this.$router.push('/login')
        }
    }
}
</script>